Skip to content

Refuse to push an encrypted project that has no encryption key - #763

Merged
quantconnect-kronos[bot] merged 1 commit into
masterfrom
kronos/bug-keyless-encrypted-push-guard
Nov 20, 2026
Merged

quantconnect-kronos[bot] merged 1 commit into
masterfrom
kronos/bug-keyless-encrypted-push-guard

Conversation

@quantconnect-kronos

Copy link
Copy Markdown
Contributor

Description

lean cloud pull of an encrypted cloud project without a key writes the project's ciphertext locally, with encrypted: true and no encryption-key-path in its config. Running lean cloud push on that project without flags then uploaded the ciphertext as ordinary source and sent an empty encryption key, which turned the cloud project's encryption off. The cloud project ended up unencrypted, but its files were still ciphertext.

PushManager._push_project now refuses to push a project whose config says it's encrypted when it has no key, either stored or given with --key. It stops before it renames, creates or updates anything, and reports:

Cannot push '<project>': its files are encrypted and it has no encryption key. Push it with --encrypt --key to keep the cloud project encrypted, or --decrypt --key to decrypt it

Both of those commands already worked for such a project. --encrypt --key uploads the ciphertext unchanged and keeps the cloud project encrypted with that key. --decrypt --key uploads plaintext and turns encryption off on purpose. Projects with a stored key, unencrypted projects and pushes with flags are unchanged. As with other push errors, the project is skipped with a warning and any other projects in a push of all projects still go through.

Testing

  • New tests in tests/commands/cloud/test_push.py, each starting with a keyless lean cloud pull of an encrypted cloud project:
    • test_cloud_push_aborts_without_updating_cloud_project_when_project_pulled_encrypted_without_key: a push without flags doesn't create or update the cloud project. Fails on master, passes here.
    • test_cloud_push_keeps_cloud_project_encrypted_when_project_pulled_encrypted_without_key_and_encrypted_flag_given: --encrypt --key sends the ciphertext and the key's hash.
    • test_cloud_push_decrypts_cloud_project_when_project_pulled_encrypted_without_key_and_decrypted_flag_given: --decrypt --key sends plaintext and an empty key.
  • python -m pytest -rs: 2902 passed, 81 skipped, 1 failed. The failure is tests/ui/test_app.py::test_command_process_runs_the_cli_as_a_child_process, which also fails on master in my environment: the child process imports an installed lean 1.0.234 instead of the checkout.
  • python static_analysis.py: passed.
  • Tested end to end against a QuantConnect API. Setup: a registered key, a project encrypted and pushed from one workspace, then pulled without a key into a second workspace and pushed from there without flags.
    • master: the push reported success. The cloud project became unencrypted, and its main.py was still the ciphertext.
    • This branch: the push printed the message above. The cloud project stayed encrypted with the same key, and its files didn't change. After that, --encrypt --key succeeded and the cloud project stayed encrypted with that key. --decrypt --key then turned encryption off and uploaded plaintext main.py.

A project pulled from an encrypted cloud project without a key keeps its
ciphertext locally with `encrypted: true` and no `encryption-key-path`.
Pushing it without flags uploaded the ciphertext as plain source and turned
the cloud project's encryption off. The push now stops before changing
anything and says to push with --encrypt --key or --decrypt --key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quantconnect-kronos quantconnect-kronos Bot added kronos:develop:working develop: in progress kronos:review Request review labels Nov 20, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 20, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 20, 2026 22:34

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The guard runs before any rename, create or update, and it only fires for an encrypted project that has neither a stored key nor --key. Projects with a stored key, unencrypted projects and pushes with --encrypt/--decrypt --key take the same path as before. The --push option of lean cloud backtest, optimize and live deploy goes through the same check. For such a project it now stops with a push error instead of sending ciphertext as plain source and turning off the cloud project's encryption. I checked that the new regression test fails on master and passes here.

I set risk:low. This is a small, easily reverted fix that replaces a destructive result with an error before anything changes. It has tests covering the refused push and both supported ways forward, green CI and an end-to-end run.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk and removed kronos:review:working review: in progress labels Nov 20, 2026
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 20, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued and removed kronos:review Request review labels Nov 20, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress and removed kronos:review:queued review: queued labels Nov 20, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I independently reproduced the failure on master and tested the fix end to end: refusing a keyless push preserves the cloud project's encryption state, key identity and files. Explicit encryption and decryption with a key both worked. All 212 cloud/encryption tests passed, and static analysis passed. I also verified that refusal precedes project creation or rename and does not stop a bulk push from processing the next project.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 20, 2026
@quantconnect-kronos
quantconnect-kronos Bot merged commit 51a654f into master Nov 20, 2026
60 checks passed
@quantconnect-kronos
quantconnect-kronos Bot deleted the kronos/bug-keyless-encrypted-push-guard branch November 20, 2026 22:47
@quantconnect-kronos quantconnect-kronos Bot removed the kronos:develop:working develop: in progress label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Low risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants